package demo1;

import java.util.Timer;
import java.util.TimerTask;

public class Test {
    public static void main(String[] args){
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("12:00 唱歌~");
            }
        }, 2000);
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("12:30 弹钢琴");
            }
        }, 3000);
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("13:00 弹吉他");
            }
        }, 4000);
        System.out.println("开始玩音乐");
    }
}
